﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ZGLXM.ErrorCode;
using ZGLXM.Writh.Api.Applicantion.Command.RBAC;

namespace ZGLXM.Writh.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProfessionController : ControllerBase
    {
        private readonly IMediator mediator;
        public ProfessionController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 添加权限信息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> InsertProfession(ProfessionInsertCommand param)
        {
            return await mediator.Send(param);
        }

        /// <summary>
        /// 删除权限信息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpDelete]
        public async Task<ApiResult> DeleteProfession([FromQuery] ProfessionDeleteCommand param)
        {
            return await mediator.Send(param);
        }


        /// <summary>
        /// 修改权限信息
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult> UpdateProfession(ProfessionUpdateCommand param)
        {
            return await mediator.Send(param);
        }
    }
}
